<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

$api = app('Dingo\Api\Routing\Router');
//前端路由
$api->version('v1', [
    'namespace' => 'App\Http\Controllers\Api',
    'middleware' => ['cors', 'serializer']
], function($api) {
        //商品详情
        $api->get('goods','GoodsController@getGoodsList');
        //商品分类
        $api->get('goodsType','GoodsTypeController@goodsType');
        //广告轮播图
        $api->get('header','BannerController@getBanner');
         //设备轮播图
         $api->get('HeaderAdvertising','MachineAbImagesController@getMachineimg');
        //货柜商户信息
        $api->get('shop','ShopController@shopInfo');
        //货柜运维信息
        $api->get('operation','OperationController@operationInfo');
        $api->get('getGoodsFreight','GoodsFreightWayController@getGoodsFreight');
        //$api->get('goods_freight_way','GoodsFreightWayController@getGoodsFreight');
        //购物车生成支付订单
        $api->post('ordercatr','OrderCatrController@payOrdercatr');
        //购物车获取微信/支付宝用户openid
        $api->get('userscatr','UserCatrController@userscatr');
        //购物车支付状态
        $api->post('orderStatuscatr','OrderCatrController@orderStatuscatr');
        $api->post('callbackOrdercatr','OrderCatrController@callbackOrdercatr');
        //获取微信/支付宝用户openid
        $api->get('users','UserController@users');
        //生成支付订单
        $api->post('order','OrderController@payOrder');
        //支付状态
        $api->post('orderStatus','OrderController@orderStatus');
        $api->post('getOrderStatus','OrderController@getOrderStatus');
        $api->post('callbackOrder','OrderController@callbackOrder'); 
        //出货状态
        $api->post('shipmentStatus','OrderController@shipmentStatus');
        //生成自动退款
        $api->post('refundOrder','OrderController@refundOrder');
    $api->group([
        'middleware' => 'api.throttle',
        'limit' => config('api.rate_limits.sign.limit'),
        'expires' => config('api.rate_limits.sign.expires'),
    ], function($api) {
        # 普通用户登录
        $api->group(['prefix' => 'auth'], function ($api) {
            $api->post('login', 'AuthController@login');
            $api->post('logout', 'AuthController@logout');
            $api->post('refresh', 'AuthController@refresh');
        });
        $api->get('mqtt/getmqtt',function(){
            dd(cache('msg'),cache('num'));
        });
        $api->get('mqtt','UserController@show');
        //需要token验证
        $api->group([
            'middleware' => 'auth:api',
        ], function($api){
            // 需要 token 验证的接口
            $api->group([
                'middleware' => ['jwt.role:user','api.auth']
            ], function($api) {
                $api->post('me', 'AuthController@me')->name('me');
                
            });
        });
    });
});

